package com.example.qxfw.backgroundManagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.qxfw.backgroundManagement.mapper.MeteorologicalPersonnelInformationManagementMapper;
import com.example.qxfw.backgroundManagement.service.MeteorologicalPersonnelInformationManagementService;
import com.example.qxfw.common.entity.IssuerInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/************************************
 *
 * @author : HuangDeYin Jolly
 * @since : JDK 11
 * @Date : 2023/7/3  星期一   16:11
 * @description : 此类用来 气象人员管理的业务接口的实现
 ***************************************/

@Service
public class MeteorologicalPersonnelInformationManagementServiceImpl extends ServiceImpl<MeteorologicalPersonnelInformationManagementMapper, IssuerInfo> implements MeteorologicalPersonnelInformationManagementService {

    @Autowired
    private MeteorologicalPersonnelInformationManagementMapper meteorologicalPersonnelInformationManagementMapper;

    @Override
    public List<IssuerInfo> selectPermission() {
        List<IssuerInfo> issuerInfos = this.meteorologicalPersonnelInformationManagementMapper.selectPermission();
        return issuerInfos;
    }

    @Override
    public IPage<IssuerInfo> selectByPermission(final String permission, int pageNo, int pageSize) {
        //List<IssuerInfo> issuerInfos = this.meteorologicalPersonnelInformationManagementMapper.selectByPermission(permission,(pageNo-1),pageSize);
        //IPage<IssuerInfo> result = this.meteorologicalPersonnelInformationManagementMapper.selectByPermission(permission,pageNo,pageSize);
        int total = this.meteorologicalPersonnelInformationManagementMapper
                .selectCount(new LambdaQueryWrapper<IssuerInfo>().eq(IssuerInfo::getPermission,permission));
        Page<IssuerInfo> page = new Page<>(pageNo, pageSize, total);
        IPage<IssuerInfo> result =this.meteorologicalPersonnelInformationManagementMapper
                .selectPage(page,new LambdaQueryWrapper<IssuerInfo>().eq(IssuerInfo::getPermission,permission));
        return result;
    }


    @Override
    public List<IssuerInfo> selectByUserName(final String userName) {
        List<IssuerInfo> issuerInfos = this.meteorologicalPersonnelInformationManagementMapper.selectByUserName(userName);
        return issuerInfos;
    }

    @Override
    public Integer insertIssuerInfo(final String userName, final String phone, final String permission) {
        Integer insertIssuerInfo = this.meteorologicalPersonnelInformationManagementMapper.insertIssuerInfo(userName, phone, permission);
        return insertIssuerInfo;
    }

    @Override
    public Integer updateIssuerInfo(final int id, final String username, final String password, final String phone, final String permission) {
        Integer updateIssuerInfo = this.meteorologicalPersonnelInformationManagementMapper.updateIssuerInfo(id, username, password, phone, permission);
        return updateIssuerInfo;
    }

    @Override
    public Integer deleteIssuerInfo(final int id) {
        Integer deleteIssuerInfo = this.meteorologicalPersonnelInformationManagementMapper.deleteIssuerInfo(id);
        return deleteIssuerInfo;
    }

    @Override
    public Integer insertByAll(IssuerInfo issuerInfo) {
        return this.meteorologicalPersonnelInformationManagementMapper.insert(issuerInfo);
    }
    @Override
    public List<IssuerInfo> selectAllIssuerInfo() {
        return this.meteorologicalPersonnelInformationManagementMapper.selectAllIssuerInfo();
    }

}
